package com.zhongkai.controller;

import com.zhongkai.app.service.SellAuditService;
import com.zhongkai.model.utils.ZhongkaiResult;
import com.zhongkai.model3.Chinaset;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 销售审核
 * */
@Controller
public class SellAuditController {

    @Autowired
    private SellAuditService sellAuditService;
    /**
     * 审批
     *
     * @param uuid       订单uuid
     */
    @RequestMapping(value = "/sell_audit/ok", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult sellIndent_ok(String uuid,HttpServletRequest httpServletRequest
    ) {

        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = sellAuditService.sellIndent_ok(uuid,chinaset.getSetName(),
                chinaset.getUuid());

        return result;
    }

    /**
     * 驳回
     *
     * @param uuid        订单uuid
     * @param remark 驳回原因
     */
    @RequestMapping(value = "/sell_audit/error", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_error(String uuid, HttpServletRequest httpServletRequest ,String remark
    ) {

        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = sellAuditService.auditIndent_error(uuid,chinaset.getSetName(),
                chinaset.getUuid(),remark);

        return result;
    }


    /**
     * 审核列表
     *
     */
    @RequestMapping(value = "/sell_audit/list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult sellIndent_list(@RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "0")Integer rows
    ) {


        ZhongkaiResult result = sellAuditService.sellIndent_list(page,rows);

        return result;
    }

}
